home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / PASROTO.ZIP / TIMER.ASM < prev    next >
Assembly Source File  |  1996-05-23  |  982b  |  78 lines

  1. ;// exact timer routines, nothing special, no copyright! ;)
  2.  
  3. .386
  4. .model flat,prolog
  5. locals
  6.  
  7. .data
  8.   tmOldTimer df 0
  9.   tmDataSeg dw 0
  10.   tmTicker dd 0
  11.  
  12. .code
  13.  
  14. tmTimerHandler proc
  15.   push ds
  16.   mov ds,cs:tmDataSeg
  17.   add ds:tmTicker,65536
  18.   pop ds
  19.   jmp cs:tmOldTimer
  20. endp
  21.  
  22. public tmInit_
  23. tmInit_ proc
  24.   mov tmDataSeg,ds
  25.   mov tmTicker,65536
  26.  
  27.   push es
  28.   mov ax,3508h
  29.   int 21h
  30.   mov dword ptr tmOldTimer+0,ebx
  31.   mov word ptr tmOldTimer+4,es
  32.   pop es
  33.  
  34.   push ds
  35.   mov ax,2508h
  36.   push cs
  37.   pop ds
  38.   mov edx,offset tmTimerHandler
  39.   int 21h
  40.   pop ds
  41.  
  42.   mov al,34h
  43.   out 43h,al
  44.   xor al,al
  45.   out 40h,al
  46.   out 40h,al
  47.   ret
  48. endp
  49.  
  50.  
  51. public tmClose_
  52. tmClose_ proc
  53.   push ds
  54.   mov ax,2508h
  55.   lds edx,tmOldTimer
  56.   int 21h
  57.   pop ds
  58.   ret
  59. endp
  60.  
  61. public tmGetTimer_
  62. tmGetTimer_ proc
  63.   pushf
  64.   cli
  65.   xor eax,eax
  66.   out 43h,al
  67.   in al,40h
  68.   mov ah,al
  69.   in al,40h
  70.   xchg ah,al
  71.   neg eax
  72.   add eax,tmTicker
  73.   popf
  74.   ret
  75. endp
  76.  
  77. end
  78.